#include <iostream>
#include <vector>
#include <string>
#include <set>

using namespace std;

class Solution
{
public:
    vector<string> res;
    set<string> tempRes;

    vector<string> permutation(string s)
    {
        if (s.size() == 0)
            return res; //字符串排列

        solvePermutation(s, &s[0]);
        for (set<string>::iterator it = tempRes.begin(); it != tempRes.end(); it++)
        {
            res.push_back(*it);
        }
        return res;
    }

    // 递归的过程
    void solvePermutation(string &s, char *sBegin)
    {
        //sBegin所指字符为空'\0'，将当前字符串s存储起来
        if (*sBegin == '\0')
            tempRes.insert(s);
        else
        {
            //将字符串s中的字符从sBegin位置开始依次和当前字符串的首字符交换位置
            for (char *sCh = sBegin; *sCh != '\0'; sCh++)
            {
                //交换位置
                char temp = *sBegin;
                *sBegin = *sCh;
                *sCh = temp;
                //交换完后继续全排列
                solvePermutation(s, sBegin + 1);
                //回溯
                temp = *sBegin;
                *sBegin = *sCh;
                *sCh = temp;
            }
        }
    }

    //封装
    int *buildNext(string &pat) //next 数组的生成
    {
        int m = pat.size();
        int j = 0;
        int *N = new int[m];
        int t = N[0] = -1; //哨兵
        while (j < m - 1)
        {
            if (t < 0 || pat[j] == pat[t])
                N[++j] = ++t;
            else
                t = N[t];
        }
        return N;
    }

    int kmp_match(string tex, string pat)
    {
        int *next = buildNext(pat); //next 数组

        int n = tex.length();
        int i = 0;

        int m = pat.length();
        int j = 0;

        while (j < m && i < n)
        {
            if (j == -1 || tex[i] == pat[j]) //匹配 检测下一个字符
            {
                i++;
                j++;
            }
            else //不匹配
            {
                j = next[j];
            }
        }
        delete[] next;
        return i - j;
    }
};


int main()
{
    Solution s;
    string s1;
    string s2;

    getline(cin, s1, '\n');
    getline(cin, s2, '\n');

    int n = s2.length() - s1.length();

    vector<string> p1 = s.permutation(s1); //生成s1的字典序 vector
    vector<string> p2;
    p2.push_back(s2);

    bool flag = false;

    for (int i = 0; i < p1.size(); i++)
    {
        int f = s.kmp_match(p2[0], p1[i]);
        if (f <= n)
        {
            cout << "true" << endl;
            flag = true;
            break; //找到符合的即可返回
        }
    }

    if (!flag)
        cout << "false" << endl;

    return 0;
}
